package com.mxsoft.concurrent;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.LongAdder;

public class PXLockDemo {


    public synchronized int add(int a, int b) {

        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        return a +b;
    }

    public static void main(String[] args) {

        PXLockDemo pxLockDemo = new PXLockDemo();

        CountDownLatch countDownLatch = new CountDownLatch(10);
        for ( int i = 0; i < 10; i ++) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    try {
                        countDownLatch.await();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    pxLockDemo.add(1, 2);
                }
            }).start();

            countDownLatch.countDown();
        }

        LongAdder longAdder = new LongAdder();
    }
}

